﻿/*****************************************************************//**
 * @file    FITKGraphObjectMeshInstance.h
 * @brief   Graph object for assembly data.
 * 
 * @sa
 * FITKColorMap FITKColorMapManager FITKGraphObjectModelHighlighting
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-03-25
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTMESHINSTANCE_H__
#define __FITKGRAPHOBJECTMESHINSTANCE_H__

#include "FITKGraphObjectMeshModelBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkActor;
class vtkTransformFilter;
class vtkTransform;

namespace Interface
{
    class FITKAssemblyInstanceM4;
    class FITKAssemblyInstanceTR;
    class FITKAbstractAssInstance;
}

namespace Exchange
{
    /**
     * @brief   Graph object for 'assembly instance'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-03-25
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectMeshInstance : public FITKGraphObjectMeshModelBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectMeshInstance, FITKGraphObjectMeshModelBase);
        FITKCLASS(Exchange, FITKGraphObjectMeshInstance);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   instance: The mesh assembly instance data with the matrix4x4 or rotate, angle and translate transform.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-03-25
         */
        FITKGraphObjectMeshInstance(AbaqusData::FITKDataCase* caseData, Interface::FITKAbstractAssInstance* instance);

        /**
         * @brief   Destructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-03-25
         */
        ~FITKGraphObjectMeshInstance();

        /**
         * @brief   Update the graph object.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-12-12
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Get the transform of the assembly instance.
         * @return  The vtkTransform
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-01
         */
        vtkTransform* getTransform();

        /**
         * @brief   Set the graph actors to the default color.[override]
         * @param   forceUpdate: Force update the color mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-09
         */
        void colorByDefault(bool forceUpdate = false) override;

        /**
         * @brief   Set the graph actors with the material's color.[override]
         * @param   forceUpdate: Force update the color mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-01
         */
        void colorByMaterial(bool forceUpdate = false) override;

        /**
         * @brief   Set the graph actors to the section's color.[override]
         * @param   forceUpdate: Force update the color mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-01
         */
        void colorBySection(bool forceUpdate = false) override;

        /**
         * @brief   Unused.[override]
         * @param   forceUpdate: Force update the color mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-12-02
         */
        void colorByDefaultProperty(bool forceUpdate = false) override
        {
            Q_UNUSED(forceUpdate);
        }

        /**
         * @brief   Set the mesh color by the mesh module.[override]
         * @param   forceUpdate: Force update the color mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-12-13
         */
        void colorByDefaultMesh(bool forceUpdate = false) override;

    private:
        /**
         * @brief   Initialize the pointers.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-23
         */
        void init();

        /**
         * @brief   Generate the actor with different type of instance transform data.
         * @param   instance: The instance data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-03-26
         */
        void generateGraph(Interface::FITKAbstractAssInstance* instance);

    private:
        /**
         * @brief   The transform added to the part.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-03-25
         */
        vtkTransform* m_transform{ nullptr };

        /**
         * @brief   The transform filter for the instance face actor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-23
         */
        vtkTransformFilter* m_transformFilterFace{ nullptr };

        /**
         * @brief   The transform filter for the instance feature actor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-23
         */
        vtkTransformFilter* m_transformFilterEdge{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTMESHINSTANCE_H__
